<extend name="Public/base"/>
<block name="head">
    <!-- DATA TABLES -->
    <link href="__PUBLIC__/plugins/datatables/dataTables.bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="__PUBLIC__/plugins/datatables/jquery.dataTables.css" rel="stylesheet" type="text/css" />
    <link href="__PUBLIC__/plugins/datatables/extensions/TableTools/css/dataTables.tableTools.min.css" rel="stylesheet" type="text/css" />
    <link href="__PUBLIC__/js/showLoading.css" rel="stylesheet" type="text/css" />
</block>

<block name="body">
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box ">
                    <div class="box-body table-responsive">
                        <table id="reprots-tables" class="table table-bordered table-striped ">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>报表名称</th>
                                <th>报表标题</th>
                                <th>状态</th>
                                <th>排序</th>
                                <th>备注</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <volist name="lists" id="report" >
                                <tr data="{$report['id']}" >
                                    <td>{$report['id']}</td>
                                    <td>{$report['report_name']}</td>
                                    <td>{$report['report_title']}</td>
                                    <td>{$report['status']|getStatus}</td>
                                    <td>{$report['report_order']}</td>
                                    <td>{$report['remark']}</td>
                                    <td>
                                        <p data-placement="top" data-toggle="tooltip"  class="col-md-6">
                                            <a href="javascript:;"  url="__URL__/edit/id/{$report['id']}" class="ajax-callback" title="Edit">
                                                <button class="btn btn-primary btn-xs"    data-title="Edit" data-toggle="modal" data-target="#edit"><span class="glyphicon  glyphicon-edit"></span> </button>
                                            </a>
                                            &nbsp;&nbsp;
                                            <a href="__URL__/user/id/{$report['id']}"  title="{$vo['name']} 用户列表" class="glyphicon glyphicon-user" style="padding: 5px"></a>
                                            <?php if($report['report_name'] == 'center_const_report'): ?>
                                                <a href="javascript:;" url="__URL__/installProfitReport" title="{$Think.lang.同步利润表数据}" onclick="Synchronous(this)" ><i class="fa fa-refresh"></i></a>
                                            <?php endif; ?>
                                            <?php if($report['report_name'] == 'balance_sheet'): ?>
                                                <!--<a href="javascript:;" url="__URL__/settingBalanceSheet" title="{$Think.lang.资产负债表设置}" ><i class="fa fa-edit"></i></a>-->
                                                <a href="javascript:;"  url="__URL__/settingBalanceSheet" class="ajax-callback" title="settingBalanceSheet">
                                                    <button class="btn btn-primary btn-xs"    data-title="SettingBalanceSheet" data-toggle="modal" data-target="#settingBalanceSheet"><i class="fa fa-edit"></i> </button>
                                                </a>
                                            <?php endif; ?>
                                        </p>
                                    </td>
                                </tr>
                            </volist>
                            </tbody>

                        </table>
                    </div><!-- /.box-body -->
                </div><!-- /.box -->
            </div><!-- /.col -->
        </div><!-- /.row -->
        </div>
        <include file="add" />
        <include file="edit" />
        <include file="settingBalanceSheet"/>
    </section><!-- /.content -->

</block>
<block name="script">

    <script src="__PUBLIC__/plugins/datatables/jquery.dataTables.min.js" type="text/javascript"></script>
    <script src="__PUBLIC__/plugins/datatables/dataTables.bootstrap.min.js" type="text/javascript"></script>
    <script src="__PUBLIC__/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.min.js" type="text/javascript"></script>
    <script src='__PUBLIC__/js/CommonPerson.js'></script>

    <script type="text/javascript">
        $(function () {

            iniDataTable("#reprots-tables",'','__URL__');
            iniAjaxFormDialog('#reprotAddForm','#add');
            iniAjaxFormDialog('#reprotEditForm','#edit');

        });

        $('.ajax-callback').bind('click',function(){
            ajaxObject.ajaxCallBackFn(this,function(result){
                var data = $.parseJSON(result);

                reprotEditForm.report_title.value = data.report_title;
                reprotEditForm.remark.value = data.remark;
                reprotEditForm.report_name.value = data.report_name;
                reprotEditForm.id.value = data.id;
                reprotEditForm.report_order.value = data.report_order;

                var cats = reprotEditForm.status.options;
                for(var j in cats){
                    if(cats[j].value == data.status){
                        cats[j].defaultSelected = true;
                        cats[j].selected = true;
                    }
                }

            });
        });

        function  Synchronous(e) {
            CommonPerson.Base.LoadingPic.FullScreenShow();
            ajaxObject.ajaxCallBackFn(e,function(result){
                if (result.status) {
                    CommonPerson.Base.LoadingPic.FullScreenHide();
                    alert('同步成功！');
                }
            })
        }


        // imageCategory  添加分类
        $(".category-btn").click(function(){
            var num = $('#category_panel div:last').find('.category-input1').val();
            if (num == undefined) num = 0;
            $("#category_panel").append(
                    '<div class="category-clone">'+
                    '<input type="text" class="category-input1" readonly value='+(parseInt(num)+1)+
                    '>'+
                    '<input type="text" name="categoryVlaue[]" class="category-input2"/>'+
                    '<input type="button" class="category-close query btn btn-default">'+
                    '</div>'
            );
        });
        //分类管理 删除分类  至少保留一个分类
        $("#category_panel").on("click",".category-close.query",function() {
            if ($(".category-close").length == 1) {
                alert("At least one classification !");
            } else {
                $(this).parent().remove();
            }
        });

    </script>

</block>